#ifndef A6_WATCARD_OFFICE
#define A6_WATCARD_OFFICE

#include <uC++.h>
#include "Printer.h"
#include <list>
#include "Bank.h"
#include "WATCard.h"
#include "Global.h"

_Task WATCardOffice 
{
    struct Args
    {
        WATCard* realCard;
        unsigned int myAmount;
        unsigned int myID;
        Args(WATCard* card, unsigned int amount, unsigned int id)
        : realCard(card), myAmount(amount), myID(id){}
    };
    
	struct Job 
	{				// marshalled arguments and return future
		Args args;				// call arguments (YOU DEFINE "Args")
		FWATCard result;			// return future
		Job( Args args ) : args( args ) {}
	};

	_Task Courier 
	{
	    WATCardOffice*  myCardOffice;
	    Bank*           myBank;
	    Printer*        myPrinter;
		unsigned int 	myID;	

		std::list<Job*> myJobmine;

		void main();
	public: 
		~Courier();
		Courier();
		void set(unsigned int id, WATCardOffice* CardOffice, Bank* bank, Printer* printer);
	};			// communicates with bank

	Printer&	myPrinter;
	Bank&		myBank;
	unsigned int myNumCouriers;
	Courier*    myCouriers;
	std::list<Job*> requests;

	void main();
public:
	_Event Lost {};
	WATCardOffice( Printer &prt, Bank &bank, unsigned int numCouriers );
	~WATCardOffice();
	FWATCard create( unsigned int sid, unsigned int amount, 
					 WATCard *&card );
	FWATCard transfer( unsigned int sid, unsigned int amount, 
					   WATCard *card );
	Job *requestWork();
};

#endif
